import { http } from "@/utils/http";

// 维修退遗费项目接口
export interface CollectMaterialItem {
  id?: number;
  repairReportsId?: number;
  status?: number;
  materialPriceList?: Array<{
    materialId: number;
    price: number;
    quantity: number;
  }>;
}

// 查询维修退遗费列表参数
export interface CollectMaterialListParams {
  page?: number;
  limit?: number;
  tenantId?: number;
  repairReportsId?: number; // 添加维修报告ID参数
}

// 查询维修退遗费列表返回结果
export interface CollectMaterialListResult {
  code: number;
  data?: object;
  message: string;
}

// 添加维修退遗费参数
export interface CollectMaterialPayload {
  repairReportsId?: number;
  repositoryId?: number; // 添加仓库ID字段
  materialPriceList?: Array<{
    materialId: number;
    price: number;
    quantity: number;
  }>;
  status?: number;
}

// 添加维修退遗费返回结果
export interface CollectMaterialCreateResult {
  code: number;
  data?: object;
  message: string;
}

/**
 * 查询维修退遗费列表
 * @param data 查询参数
 * @returns 维修退遗费列表数据
 */
export const getCollectMaterialList = (data: CollectMaterialListParams) => {
  return http.request<CollectMaterialListResult>("post", "/collectMaterials/list", { data });
};

/**
 * 添加维修退遗费信息
 * @param data 维修退遗费信息
 * @returns 创建结果
 */
export const addCollectMaterial = (data: CollectMaterialPayload) => {
  return http.request<CollectMaterialCreateResult>("post", "/collectMaterials/add", { data });
};